package nowCoder;

import java.util.*;

public class HJ94 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        Object[][] m = new Object[r][2];
        for (int i = 0; i < r; i++) {
            m[i][0] = sc.next();
            m[i][1] = 0;
        }
        int p = sc.nextInt();
        int n = 0;
        ln:
        for (int i = 0; i < p; i++) {
            String x = sc.next();
            for (int j = 0; j < r; j++) {
                if (x.equals(m[j][0])){
                    m[j][1] = Integer.parseInt(String.valueOf(m[j][1])) + 1;
                    continue ln;
                }
            }
            n++;
        }
        for (int i = 0; i < r; i++) {
            System.out.println(m[i][0]+" : "+m[i][1]);
        }
        System.out.println("Invalid : "+n);
    }
}
